home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / BLAZER.PAK / PROPDLGS.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  6KB  |  220 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1995 by Borland International, All Rights Reserved
  4. //
  5. // Implementation of the property pages TSpeedPage and TBitBltPage
  6. //----------------------------------------------------------------------------
  7. #include <owl/pch.h>
  8. #include "blazer.h"
  9. #include "propdlgs.h"
  10.  
  11. //
  12. // Declare some constant ranges for the random factor, delta, and delay values.
  13. //
  14. const int RandomFactorLower = 2;
  15. const int RandomFactorUpper = 12;
  16. const int DeltaLower = 5;
  17. const int DeltaUpper = 15;
  18. const int DelayLower = 1;
  19. const int DelayUpper = 20;
  20.  
  21. DEFINE_RESPONSE_TABLE1(TSpeedPage, TPropertyPage)
  22.   EV_WM_HELP,
  23. END_RESPONSE_TABLE;
  24.  
  25. DEFINE_HELPCONTEXT(TSpeedPage)
  26.   HCENTRY_CONTROL(IDH_RANDOM,  IDC_RANDOM),
  27.   HCENTRY_CONTROL(IDH_DELTA,   IDC_DELTA),
  28.   HCENTRY_CONTROL(IDH_DELAY,   IDC_DELAY),
  29. END_HELPCONTEXT;
  30.  
  31. //
  32. // Constructor to initialize values.
  33. //
  34. TSpeedPage::TSpeedPage(int factor, int delta, int delay, TPropertySheet* parent,
  35.   TResId resId, const char far* title, TResId iconRes, TModule* module)
  36. :
  37.   FactorValue(factor),
  38.   DeltaValue(delta),
  39.   DelayValue(delay),
  40.   TPropertyPage(parent, resId, title, iconRes, module)
  41. {
  42.   // These are place holders for where the real gauge controls are to
  43.   // be positioned since TGauges are not real custom controls.
  44.   //
  45.   DeltaPlace        = new TStatic(this, IDC_DELTAPLACE);
  46.   RandomFactorPlace = new TStatic(this, IDC_RANDOMPLACE);
  47.   DelayPlace        = new TStatic(this, IDC_DELAYPLACE);
  48. }
  49.  
  50.  
  51. //
  52. // SetupWindow().
  53. // Now that the static place-holder controls are created, we can determine
  54. // their locations using GetWindowRect and create TGauges at those locations.
  55. // Since the place-holder controls are not visible, the gauges will appear to
  56. // have been created along with the dialog.
  57. //
  58. void
  59. TSpeedPage::SetupWindow()
  60. {
  61.   // Ensure child static controls are created.
  62.   //
  63.   TPropertyPage::SetupWindow();
  64.  
  65.  
  66.   SETUP_HELPCONTEXT(TBlazerApp, TSpeedPage);
  67.  
  68.   TRect windowRect;
  69.   TPoint p;
  70.  
  71.   // Create the random factor gauge and set its range and position.
  72.   //
  73.   windowRect = RandomFactorPlace->GetWindowRect();
  74.   p = windowRect.TopLeft();
  75.   ScreenToClient(p);
  76.   RandomFactor = new THSlider(this, IDC_RANDOM,
  77.     p.x, p.y, windowRect.Width(), windowRect.Height());
  78.   RandomFactor->Create();
  79.   RandomFactor->SetRange(RandomFactorLower, RandomFactorUpper);
  80.   RandomFactor->SetPosition(FactorValue);
  81.  
  82.   // Create the delta gauge and set its range and position.
  83.   //
  84.   windowRect = DeltaPlace->GetWindowRect();
  85.   p = windowRect.TopLeft();
  86.   ScreenToClient(p);
  87.   Delta = new THSlider(this, IDC_DELTA,
  88.     p.x, p.y, windowRect.Width(), windowRect.Height());
  89.   Delta->Create();
  90.   Delta->SetRange(DeltaLower, DeltaUpper);
  91.   Delta->SetPosition(DeltaValue);
  92.  
  93.   // Create the delay gauge and set its range and position.
  94.   //
  95.   windowRect = DelayPlace->GetWindowRect();
  96.   p = windowRect.TopLeft();
  97.   ScreenToClient(p);
  98.   Delay = new THSlider(this, IDC_DELAY,
  99.     p.x, p.y, windowRect.Width(), windowRect.Height());
  100.   Delay->Create();
  101.   Delay->SetRange(DelayLower, DelayUpper);
  102.   Delay->SetPosition(DelayValue);
  103. }
  104.  
  105. //
  106. // CleanupWindow()
  107. //
  108. void
  109. TSpeedPage::CleanupWindow()
  110. {
  111.   // Save the position of the gauges
  112.   //
  113.   FactorValue = RandomFactor->GetPosition();
  114.   DeltaValue  = Delta->GetPosition();
  115.   DelayValue  = Delay->GetPosition();
  116.  
  117.   CLEANUP_HELPCONTEXT(TBlazerApp, TSpeedPage);
  118.  
  119.   TPropertyPage::CleanupWindow();
  120. }
  121.  
  122. //
  123. // Forward WM_HELP messages up to application.
  124. //
  125. void
  126. TSpeedPage::EvHelp(HELPINFO* hi)
  127. {
  128.   ::Application->GetMainWindow()->SendMessage(WM_HELP, 0, TParam2(hi));
  129. }
  130.  
  131.  
  132. //
  133. // Constructor to initialize values.
  134. //
  135. TBitBltPage::TBitBltPage(bool blitterBlocks, bool sound,
  136.   TPropertySheet* parent, TResId resId,
  137.   const char far* title, TResId iconRes, TModule* module)
  138. :
  139.   BlitterBlocks(blitterBlocks),
  140.   EnableSound(sound),
  141.   TPropertyPage(parent, resId, title, iconRes, module)
  142. {
  143.   Destructive = new TRadioButton(this, IDC_DESTRUCTIVE);
  144.   Sprite      = new TRadioButton(this, IDC_SPRITE);
  145.   Sound       = new TCheckBox(this, IDC_SOUND);
  146. }
  147.  
  148.  
  149. //
  150. // SetupWindow().
  151. //
  152. void
  153. TBitBltPage::SetupWindow()
  154. {
  155.   TPropertyPage::SetupWindow();
  156.   SETUP_HELPCONTEXT(TBlazerApp, TBitBltPage);
  157.  
  158.   if (BlitterBlocks)
  159.     Destructive->Check();
  160.   else
  161.     Sprite->Check();
  162.  
  163.   if (EnableSound)
  164.     Sound->Check();
  165.   else
  166.     Sound->Uncheck();
  167. }
  168.  
  169. //
  170. // CleanupWindow().
  171. //
  172. void
  173. TBitBltPage::CleanupWindow()
  174. {
  175.   EnableSound = Sound->GetCheck() == BF_CHECKED ? true : false;
  176.   CLEANUP_HELPCONTEXT(TBlazerApp, TBitBltPage);
  177.   TPropertyPage::CleanupWindow();
  178. }
  179.  
  180. DEFINE_RESPONSE_TABLE1(TBitBltPage, TPropertyPage)
  181.   EV_WM_HELP,
  182.   EV_BN_CLICKED(IDC_DESTRUCTIVE, BnDestructiveClicked),
  183.   EV_BN_CLICKED(IDC_SPRITE     , BnSpriteClicked),
  184. END_RESPONSE_TABLE;
  185.  
  186. DEFINE_HELPCONTEXT(TBitBltPage)
  187.   HCENTRY_CONTROL(IDH_DESTRUCTIVE, IDC_DESTRUCTIVE),
  188.   HCENTRY_CONTROL(IDH_SPRITE,      IDC_SPRITE),
  189.   HCENTRY_CONTROL(IDH_SOUND,       IDC_SOUND),
  190. END_HELPCONTEXT;
  191.  
  192. //
  193. //
  194. //
  195. void
  196. TBitBltPage::BnDestructiveClicked()
  197. {
  198.   BlitterBlocks = true;
  199. }
  200.  
  201. //
  202. //
  203. //
  204. void
  205. TBitBltPage::BnSpriteClicked()
  206. {
  207.   BlitterBlocks = false;
  208. }
  209.  
  210. //
  211. // Forward WM_HELP messages up to application.
  212. //
  213. void
  214. TBitBltPage::EvHelp(HELPINFO* hi)
  215. {
  216.   ::Application->GetMainWindow()->SendMessage(WM_HELP, 0, TParam2(hi));
  217. }
  218.  
  219.  
  220.